xquery version "1.0";

declare namespace pm = "http://www.politicalmashup.nl";

import module namespace layout="http://www.example.com/layout" at "xmldb:exist:///db/projdb/modules/layout.xqm";
import module namespace addf="http://www.example.com/addf" at "xmldb:exist:///db/projdb/modules/addf.xqm";
import module namespace activity="http://www.example.com/activity" at "xmldb:exist:///db/projdb/modules/activity.xqm";
import module namespace request="http://exist-db.org/xquery/request";


declare option exist:serialize "doctype-public=-//W3C//DTD&#160;XHTML&#160;1.1//EN
                                doctype-system=http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";

declare variable $individualID {xs:string(request:get-parameter("id", ()))};
declare variable $individualTupel {doc('/db/projdb/participatie_parameters_ge2009.xml')/result/tupel[@ref=$individualID]};
declare variable $individualName {data($individualTupel/speaker)};

declare variable $iandp_file {doc('/db/projdb/initiators_and_participants_ge2009.xml')};

declare variable $initiative-titels {
    <ul xmlns="http://www.w3.org/1999/xhtml" class="topicTitels">
    {
        for $a at $position in activity:topic-titels-from-initiator($iandp_file, $individualName)/topics/topic
            let $title := data($a/title)
        return
            <li class="{if($position mod 2 = 0) then 'evenItem' else 'oddItem'}"><p>{$position}. {substring-before($title, $individualName)}<u>{$individualName}</u>{substring-after($title, $individualName)} <br/><strong>Agendapunt op: </strong> {for $id at $p in $a/id return (if ($p > 1) then ' | '  else '', <a href="topic.xql?id={data($id)}&amp;individualID={$individualID}">{addf:readableDate(data($id/@date))}</a>)}</p></li> 
    }
    </ul>
};

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Activiteit in de plenaire vergaderingen</title>
        <link rel="stylesheet" style="text/css" href="style/core_layout.css"/>	
		<script type="text/javascript" src="js/jquery.js"><!-- --></script>
        <script type="text/javascript" src="js/myScripts.js"><!-- --></script>
        
        
    </head>
    <body>	
          <div class="containerBox">
        {layout:topMenu()}  
 
        <div class="box" id="titleBox">
            <div class="margin">
                <h1><a href="individual.xql?id={$individualID}">{$individualName}</a>: {count($initiative-titels/li)} initiatieven</h1>
            </div>
        </div>

        <div class="box" id="initiativesChartBox">
            <div class="margin">
                <h2 class="boxTitle hiddenElement">Initiatieven</h2>
                <div class="boxContent">
                    <div id="initiativesContainer">
                        {$initiative-titels}
                    </div>
                </div>
            </div>
        </div>
</div>
    </body>
</html>
